package ext.tianma.bom.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.rmi.RemoteException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import org.apache.commons.lang.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import wt.fc.Identified;
import wt.fc.IdentityHelper;
import wt.fc.PersistenceHelper;
import wt.fc.PersistenceServerHelper;
import wt.part.QuantityUnit;
import wt.part.WTPart;
import wt.part.WTPartMaster;
import wt.part.WTPartMasterIdentity;
import wt.session.SessionServerHelper;
import wt.util.WTException;
import wt.util.WTInvalidParameterException;
import wt.util.WTProperties;
import wt.util.WTPropertyVetoException;
import wt.vc.views.ViewReference;
import com.ibm.icu.text.NumberFormat;
import com.ptc.cat.entity.client.Exception;
import com.ptc.core.components.beans.ObjectBean;
import com.ptc.core.components.forms.FormResult;
import com.ptc.netmarkets.util.beans.NmCommandBean;
import com.ptc.windchill.enterprise.part.forms.CreatePartAndCADDocFormProcessor;

import ext.com.core.CoreUtil;
import ext.com.iba.IBAUtil;
import ext.generic.part.CusIBAUtil;
import ext.generic.util.Generic;
import ext.tianma.part.PartDescriptionUtil;
import ext.tianma.part.forms.PartUtil;
import ext.tianma.part.util.ClassificationUtil;

/**
 * copy from CreateNewPartFormProcessor for 批量创建半成品  部分方法由private改为public
 * @author gjw
 *
 */
public class CreateNewPartFormUtil  {
	private static final String CLASSNAME = CreateNewPartFormUtil.class
			.getName();

	private static final String PART_HANDLE = "partHandle";

	private static boolean VERBOSE = false;

	private static String materialExcelPath = "";

	private static String twomaterialExcelPath = "";

	public static WTProperties wtProperties = null;

	private static final String V_DESIGN = "Design";

	// 属性文件路径
	private static String filePath = "/ext/tianma/cfg/TianmaPro.properties";

	private static List<String> viewList = new ArrayList();

	static {
		try {
			wtProperties = WTProperties.getLocalProperties();

			VERBOSE = wtProperties.getProperty("ext.generic.part.verbose",
					false);

			materialExcelPath = wtProperties
					.getProperty("ext.tianma.part.materials");
			twomaterialExcelPath = wtProperties
					.getProperty("ext.tianma.part.twomaterials");

			viewList.add("C01");
			viewList.add("C02");
			viewList.add("C04");
//			viewList.add("C06");
			viewList.add("C08");
		} catch (Throwable throwable) {
			throw new ExceptionInInitializerError(throwable);
		}
	}



	public void updateAVLName(WTPart part) {
		String classificationPath = ClassificationUtil.queryClassificationPath(part);
		if(StringUtils.isNotBlank(classificationPath) ){
			String name = StringUtils.substringAfterLast(classificationPath, "\\").trim();
			changePartIndentity(part, name, "");
		}
		
	}

	public boolean checkFinishedGoodNumber(WTPart part) throws WTPropertyVetoException, WTException {
		boolean flag = false;
		String partNumber = part.getNumber();
		System.out.println("成品的编码：" + partNumber);
		partNumber = partNumber.replace(" ", "");
		String regx = "[\\w#-]*";
		flag = partNumber.matches(regx);
		if(flag){
			Identified partidentified = (Identified) part.getMaster();
			WTPartMasterIdentity identity = (WTPartMasterIdentity) partidentified.getIdentificationObject();
			identity.setNumber(partNumber);
			IdentityHelper.service.changeIdentity(partidentified, identity);
			PersistenceHelper.manager.save(partidentified);
		}
		System.out.println("成品去掉空格后的编码：" + part.getNumber() + "flag:" + flag);
		return flag;
	}

	public static Map<Boolean, String> checkDisplayModel(WTPart part) throws WTException {
		String displayModel="";
		boolean flag = false;
		Map<Boolean, String> map = new HashMap<Boolean, String>();
		String errorInfo = "显示模式和是否专显字段不能为空";
		try {
			displayModel = (String) IBAUtil.getIBAValue(part,
					"finishedGoodDisplayMode");

			String specialMonitor = (String) IBAUtil.getIBAValue(part,
					"specialMonitor");
			if (displayModel != null && !displayModel.isEmpty()
					&& specialMonitor != null && !specialMonitor.isEmpty()) {
				Object displayModelValue = null;
				if ("是".equals(specialMonitor)) {
					displayModelValue = Generic.getStrFromProperties(
							"PD.finishedGoodDisplayMode", filePath);
					errorInfo = "所选显示模式不应用于专显产品，请修改!";
				} else if ("否".equals(specialMonitor)) {
					displayModelValue = Generic.getStrFromProperties(
							"CD.finishedGoodDisplayMode", filePath);
					errorInfo = "所选显示模式不应用于消费品产品，请修改!";
				}
				System.out
						.println("checkDisplayModel method displayModelValue="
								+ displayModelValue + ",displayModel = " + displayModel);
				if (displayModelValue != null) {
					List<String> displayModelValueList = Arrays
							.asList((displayModelValue.toString().split("-")));
					System.out
							.println("checkDisplayModel method displayModelValueList="
									+ displayModelValueList.toString());
					flag = displayModelValueList.contains(displayModel);
					System.out.println("checkDisplayModel method flag=" + flag);

				}
			}
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}	
		map.put(flag, errorInfo);
		return map;
	}

	/**
	 * 判断填写的上偏光片料号是否存在
	 * 
	 * @param part
	 * @throws WTException
	 * @throws RemoteException
	 */
	public static void checkBotPolarizerAtt(WTPart part) throws WTException {
		String MtlNumofPOLTop = "";
		try {
			MtlNumofPOLTop = (String) IBAUtil.getIBAValue(part,
					"MtlNumofPOLTop");
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (MtlNumofPOLTop != null && !"".equals(MtlNumofPOLTop)) {
			WTPart topWtPart = CoreUtil.getWTPartByNumberAndView(
					MtlNumofPOLTop, "Design");
			if (topWtPart == null) {
				throw new WTException("偏光片对应的料号不存在，请重新填写！");
			}
		}
	}

	/**
	 * 判断填写的下偏光片料号是否存在
	 * 
	 * @param part
	 * @throws WTException
	 * @throws RemoteException
	 */
	public static void checkTopPolarizerAtt(WTPart part) throws WTException {
		String MtlNumofPOLBtn = "";
		String isBothNewPolarizer = "";
		try {
			MtlNumofPOLBtn = (String) IBAUtil.getIBAValue(part,
					"MtlNumofPOLBtn");
			isBothNewPolarizer = (String) IBAUtil.getIBAValue(part,
					"isBothNewPolarizer");
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		if ("否".equals(isBothNewPolarizer) && MtlNumofPOLBtn != null
				&& !MtlNumofPOLBtn.trim().isEmpty()) {
			WTPart botWtPart = CoreUtil.getWTPartByNumberAndView(
					MtlNumofPOLBtn, "Design");
			if (botWtPart == null) {
				throw new WTException("偏光片对应的料号不存在，请重新填写！");
			}
		}
	}

	/**
	 * 从当前原材料的“中英文名称”属性分别拆分出“英文名称”和“中文名称”并设置。
	 * 
	 * @param part
	 */
	public static void setCNAndENName(WTPart part) {
		if (part == null) {
			return;
		}

		try {
			String partCNAndENName = (String) IBAUtil.getIBAValue(part,
					"partCNAndENName");

			if (partCNAndENName != null) {
				partCNAndENName = partCNAndENName.trim();

				System.out
						.println(">>>>> partCNAndENName = " + partCNAndENName);

				String[] names = partCNAndENName.split("--");

				if (names != null && names.length == 2) {
					if (names[0] != null) {
						names[0] = names[0].trim();
						if (!names[0].equals("")) {
							IBAUtil.forceSetIBAValue(part, "partEName",
									names[0]);
						}
					}

					if (names[1] != null) {
						names[1] = names[1].trim();
						if (!names[1].equals("")) {
							IBAUtil.forceSetIBAValue(part, "partCName",
									names[1]);
						}
					}
				}

			}
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (WTException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 校验虚拟偏光片的尺寸是否保留两位小数
	 * 
	 * @param part
	 * @return boolean
	 * @throws WTException
	 * @throws RemoteException
	 * @throws NumberFormatException
	 * @throws WTPropertyVetoException
	 */
	public static boolean checkPartSize(WTPart part) throws WTException,
			RemoteException, NumberFormatException, WTPropertyVetoException {
		boolean flag = false;
		if (part == null) {
			return flag;
		}
		String partSize = (String) IBAUtil.getIBAValue(part, "partSize");
		// 判断是否为整数或者保留两位小数的正则表达式
		String regx = "(0|([1-9][0-9]*))(\\.[0-9]{1,2})f?";
		if (partSize != null) {
			if (partSize.matches(regx)) {
				DecimalFormat df = new DecimalFormat("0.00");
				partSize = df.format(Double.parseDouble(partSize));
				IBAUtil.forceSetIBAValue(part, "partSize", partSize);
				if (VERBOSE)
					System.out.println("<<< " + CLASSNAME
							+ ".输出信息,字符串partSize:" + "IBA属性："
							+ (String) IBAUtil.getIBAValue(part, "partSize"));
				flag = true;
			}
		}
		if (VERBOSE)
			System.out.println("<<< " + CLASSNAME + ".输出信息,flag:" + flag);
		return flag;
	}

	/**
	 * 更新原材料物料属性
	 * 
	 * @param part
	 * @throws WTException
	 */
	public static void updateRawMaterialInfo(WTPart part) throws WTException {
		try {
			String china = (String) IBAUtil.getIBAValue(part, "partCName");

			if (null == china || china.equals("")) {
				throw new WTException("原材料中文名称为不能为空，请填写！");
			}

			// 检查零部件料号生效产地是否重复
			checkPartNumberEffectiveSite(part);

			part = changePartIndentity(part, china, null);

			PartDescriptionUtil.setPartDescription(part);

			PartDescriptionUtil.setPartDescriptionDetail(part);
			// 更新零部件默认单位
			String value = (String) IBAUtil.getIBAValue(part, "partEName");
			String unit = PartUtil.getRawMaterialsUnit(
					getWorkbook(materialExcelPath).getSheetAt(1), value);
			changePartUnit(part, unit);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 更新FPC_PCB类型的二级物料的物料属性
	 * 
	 * @param part
	 */
	public void updateFPC_PCB(WTPart part) {
		try {
			String namevalue = (String) IBAUtil.getIBAValue(part,
					"TwoMaterialName");
			outDebugInfo("FPC_PCB >>>>>>>>>>>>>>>>>>>namevalue=" + namevalue);

			String shellnamevalue = PartUtil.getTwoMaterialName(
					getWorkbook(twomaterialExcelPath).getSheetAt(0), namevalue);
			outDebugInfo("FPC_PCB二级类的shell值：" + shellnamevalue);

			if (shellnamevalue != null) {
				String[] twomaterials = splitStr(shellnamevalue);

				String onename = twomaterials[1];
				String twovalue = twomaterials[0];

				String waterCode = getWaterCode("FPC_PCBID_seq", 7);

				String[] bulNumArray = { onename, twovalue, waterCode };
				String bluNum = jointString(bulNumArray, "");

				changePartIndentity(part, namevalue, bluNum);
			}
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (WTException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 更新BLU类型的二级物料的物料属性
	 * 
	 * @param part
	 */
	private void updateBLUInfo(WTPart part) {
		try {
			String namevalue = (String) IBAUtil.getIBAValue(part,
					"TwoMaterialName");
			outDebugInfo("BLU >>>>>>>>>>>>>>>>>>>namevalue=" + namevalue);

			// String onename="1";
			String shellnamevalue = PartUtil.getTwoMaterialName(
					getWorkbook(twomaterialExcelPath).getSheetAt(0), namevalue);
			outDebugInfo("BLU二级类的shell值：" + shellnamevalue);
			if (shellnamevalue != null) {
				String[] twomaterials = splitStr(shellnamevalue);

				String onename = twomaterials[1];
				String twovalue = twomaterials[0];

				String waterCode = getWaterCode("BLUID_seq", 7);

				String[] bulNumArray = { onename, twovalue, waterCode };
				String bluNum = jointString(bulNumArray, "");

				changePartIndentity(part, namevalue, bluNum);
			}
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (WTException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 更新半成品的物料属性信息
	 * 
	 * @param part
	 */
	public static void updateSemiFinishedGoodInfo(WTPart part) {
		try {
			String[] materials = getSemiFinishedGoodConfigInfo(part);

			// 中文名称
			String china = materials[1];
			// 英文名称
			String english = materials[2];
			// 单位
			String unit = materials[3];

			// 更新物料名称
			part = changePartIndentity(part, china, null);

			// 更新物料单位
			changePartUnit(part, unit);

			PartDescriptionUtil.setPartDescription(part);

			// 设置英文名称
			IBAUtil.forceSetIBAValue(part, "partEName", english);
		} catch (WTException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 获取半成品的配置信息
	 * 
	 * @param part
	 * @return
	 * @throws WTException
	 * @throws RemoteException
	 */
	public static  String[] getSemiFinishedGoodConfigInfo(WTPart part)
			throws WTException, RemoteException {
		String[] materials = null;

		// 获取 半成品分类 的值
		String smallTypevalue = (String) IBAUtil.getIBAValue(part,
				"SemiFinishedGoodType");

		outDebugInfo("半成品分类 的值 ：value=" + smallTypevalue);

		if (smallTypevalue != null) {
			String materialsName = PartUtil.getLitteClassCode(
					getWorkbook(materialExcelPath).getSheetAt(0),
					smallTypevalue);

			outDebugInfo("materialsName=" + materialsName);

			if (materialsName != null && materialsName.length() > 0) {
				materials = splitStr(materialsName);
			} else {
				throw new Exception("系统中未配置半成品分类对应的类型,请联系系统管理员!");
			}
		}

		return materials;
	}

	/**
	 * 获取流水码
	 * 
	 * @param seqName
	 * @param codeLength
	 * @return String
	 * @throws WTException
	 */
	public String getWaterCode(String seqName, int codeLength)
			throws WTException {
		String waterCode = PersistenceHelper.manager.getNextSequence(seqName);

		if (waterCode != null) {
			NumberFormat nf = NumberFormat.getInstance();
			nf.setMinimumIntegerDigits(codeLength);
			nf.setMaximumIntegerDigits(codeLength);
			nf.setGroupingUsed(false);

			waterCode = nf.format(Integer.parseInt(waterCode.trim()));
		}

		if (waterCode == null) {
			waterCode = "";
		}

		return waterCode;
	}

	/**
	 * 检查零部件的物料生效地是否重复
	 * 
	 * @param part
	 * @throws WTException
	 * @throws RemoteException
	 */
	private static void checkPartNumberEffectiveSite(WTPart part)
			throws WTException, RemoteException {
		Vector effvector = IBAUtil
				.getIBAValue2(part, "partNumberEffectiveSite");

		if (null == effvector || effvector.size() == 0) {
			throw new WTException("物料生效产地为不能为空，请填写！");
		}

		System.out.println("Debug 创建原材料或子键  物料生效地集合：" + effvector.toString()
				+ "  " + effvector.size());
		Vector<String> v = new Vector<String>();
		for (int i = 0; i < effvector.size(); i++) {
			String temp = (String) effvector.get(i);

			System.out.println("Debug 创建原材料或子键  物料生效地" + i + ":" + temp);

			if (v.contains(temp)) {
				throw new WTException("物料生效产地重复请填写，请填写！");
			}

			v.add(temp);
		}
	}

	/**
	 * 更改零部件的标识符，包括：零部件编号和零部件名称，并且要求两者的新值至少有一个有意义
	 * 
	 * @param part
	 * @param newName
	 * @param newNum
	 * @return
	 */
	public static WTPart changePartIndentity(WTPart part, String newName,
			String newNum) {
		if (part == null) {
			return part;
		}

		newName = convertNullStr(newName);
		newNum = convertNullStr(newNum);

		if (newName.equals("") && newNum.equals("")) {
			return part;
		}

		try {
			Identified partidentified = (Identified) part.getMaster();
			WTPartMasterIdentity partmasteridentity = (WTPartMasterIdentity) partidentified
					.getIdentificationObject();

			// 设置名称
			if (!newName.equals("")) {
				partmasteridentity.setName(newName);
			}

			// 设置编号
			if (!newNum.equals("")) {
				partmasteridentity.setNumber(newNum);
			}

			partidentified = IdentityHelper.service.changeIdentity(
					partidentified, partmasteridentity);
			PersistenceServerHelper.manager.update(partidentified);
			part = (WTPart) PersistenceHelper.manager.refresh(part);
		} catch (WTException e) {
			e.printStackTrace();
		} catch (WTPropertyVetoException e) {
			e.printStackTrace();
		}

		return part;
	}

	public static void updatePartNumberEffectiveSite(WTPart part)
			throws RemoteException, WTException {
		if (part == null) {
			return;
		}

		String currentEffectiveSite = "";

		Vector arraycurrentEffectiveSite = IBAUtil.getIBAValue2(part,
				"partNumberEffectiveSite");

		if ((arraycurrentEffectiveSite != null)
				&& (arraycurrentEffectiveSite.size() > 0)) {
			for (int i = 0; i < arraycurrentEffectiveSite.size(); i++) {
				if (!((String) arraycurrentEffectiveSite.get(i)).trim()
						.isEmpty()) {
					if (currentEffectiveSite.trim().isEmpty())
						currentEffectiveSite = ((String) arraycurrentEffectiveSite
								.get(i)).trim();
					else {
						currentEffectiveSite = currentEffectiveSite
								+ ","
								+ ((String) arraycurrentEffectiveSite.get(i))
										.trim();
					}
				}
			}
		}
		System.out.println("Debug   当前原材料料号生效产地：" + currentEffectiveSite);
		if (currentEffectiveSite != null) {
			currentEffectiveSite = currentEffectiveSite.trim();

			if (currentEffectiveSite.contains("C0")) {
				for (int i = 0; i < viewList.size(); i++) {
					String organization = (String) viewList.get(i);

					if (!currentEffectiveSite.contains(organization)) {
						currentEffectiveSite = currentEffectiveSite + ","
								+ organization;
					}

				}

				CusIBAUtil.forceSetEnumIBAValue(part,
						"partNumberEffectiveSite", currentEffectiveSite);
			}
		}
	}

	/**
	 * 修改零部件的默认单位
	 * 
	 * @param part
	 * @param unit
	 */
	public static void changePartUnit(WTPart part, String unit) {
		if (part == null) {
			outDebugInfo(">>>>> 设置单位, part == null");
			return;
		}

		if (unit == null || unit.equals("")) {
			outDebugInfo(">>>>> 设置单位, unit == null");
			return;
		}

		QuantityUnit quantityUnit = QuantityUnit.toQuantityUnit(unit);

		if (quantityUnit != null) {
			WTPartMaster partMaster = (WTPartMaster) part.getMaster();

			try {
				outDebugInfo(">>>>> 开始设置单位！");

				// 更新单位
				partMaster.setDefaultUnit(quantityUnit);
				partMaster = (WTPartMaster) PersistenceHelper.manager
						.save(partMaster);

				outDebugInfo(">>>>> 设置单位成功！");
			} catch (WTInvalidParameterException e) {
				e.printStackTrace();
			} catch (WTPropertyVetoException e) {
				e.printStackTrace();
			} catch (WTException e) {
				e.printStackTrace();
			}
		} else {
			outDebugInfo(">>>>> 设置单位, 单位为空." + unit + " 不能转换为单位.");
		}
	}

	public static String convertNullStr(String str) {
		if (str == null) {
			str = "";
		}

		str = str.trim();

		return str;
	}

	public static String[] splitStr(String value) {
		String[] list = null;

		if (value != null && !value.equals("")) {
			list = value.split(",");
		}

		return list;
	}

	public static String jointString(String[] strArray) {
		String defaultConnectStr = "-";
		return jointString(strArray, defaultConnectStr);
	}

	public static String jointString(String[] strArray, String connectStr) {
		String result = "";

		if (strArray == null || strArray.length == 0) {
			return result;
		}

		if (connectStr == null) {
			connectStr = "";
		}

		for (int i = 0; i < strArray.length; i++) {
			if (strArray[i] != null) {
				strArray[i] = strArray[i].trim();

				if (!strArray[i].equals("")) {
					if (result.length() == 0) {
						result = strArray[i];
					} else {
						result = result + connectStr + strArray[i];
					}
				}
			}
		}

		return result;
	}

	// 输出日志
	public static void outDebugInfo(String info) {
		if (VERBOSE)
			System.out.println("<<< " + CLASSNAME + "." + info);
	}

	public static Workbook getWorkbook(String path) {
		Workbook workbook = null;

		InputStream in = null;

		try {
			in = new FileInputStream(path);

			workbook = WorkbookFactory.create(in);
		} catch (IOException e1) {
			e1.printStackTrace();
		} catch (InvalidFormatException e) {
			e.printStackTrace();
		} finally {
			closeStream(in);

			if (workbook == null) {
				outDebugInfo(">>>>> Can't get Excel Workbook by excel file path : "
						+ path);
			}
		}

		return workbook;
	}

	public static void closeStream(InputStream in) {
		if (in != null) {
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * 创建零部件时检查视图是否为“Design”
	 * 
	 * 如果为“Design”视图时返回false
	 * 
	 * @param part
	 */
	public static boolean checkNewPartView(WTPart part) {
		boolean checkNewPartView = false;

		if (part == null) {
			return checkNewPartView;
		}
		ViewReference viewReference = part.getView();
		System.out.println("Debug   viewReference:" + viewReference);
		if (viewReference == null) {
			return true;
		}
		if (part.getViewName() != null || !part.getViewName().trim().isEmpty()) {
			if (!part.getViewName().equals(V_DESIGN)) {
				checkNewPartView = true;
			}
		}

		return checkNewPartView;
	}

	/*
	 * public static Vector getClassNodesByPart(WTPart wtpart) throws
	 * WTException { if(VERBOSE)
	 * System.out.println(">>>enter CSMUtil.getClassNodesByPart()"); Vector
	 * clfNodes = new Vector(); IBAHolder ibaHolder = null; try { ibaHolder =
	 * IBAValueHelper
	 * .service.refreshAttributeContainerWithoutConstraints(wtpart);
	 * DefaultAttributeContainer theContainer =
	 * (DefaultAttributeContainer)ibaHolder.getAttributeContainer();
	 * if(theContainer != null) { System.out.println("theContainer:" +
	 * theContainer); System.out.println("theContainer.getAttributeValues():" +
	 * theContainer.getAttributeValues());
	 * System.out.println("theContainer.getAttributeDefinitions():" +
	 * theContainer.getAttributeDefinitions());
	 * 
	 * 
	 * AttributeDefDefaultView theAtts[] =
	 * theContainer.getAttributeDefinitions(); String clfRefDef = ""; clfRefDef
	 * = getClassificationRefDefinition(); for(int i = 0; i < theAtts.length;
	 * i++){ System.out.println("theAtts[i].getName():" +
	 * theAtts[i].getName().toString());
	 * System.out.println("theAtts[i].getName():" +
	 * theAtts[i].getName().toString());
	 * if(theAtts[i].getName().equalsIgnoreCase(clfRefDef)) { if(VERBOSE)
	 * System.out.println((new
	 * StringBuilder("    the attribute name is ")).append
	 * (clfRefDef).toString()); } else { if(VERBOSE) System.out.println((new
	 * StringBuilder
	 * ("    the attribute name is ")).append(theAtts[i].getName().toString()));
	 * AbstractValueView theValues[] =
	 * theContainer.getAttributeValues(theAtts[i]); if(theValues != null) {
	 * for(int j = 0; j < theValues.length; j++) if(theValues[j] instanceof
	 * ReferenceValueDefaultView) { String sNodeId =
	 * ((ReferenceValueDefaultView)
	 * theValues[j]).getLiteIBAReferenceable().getReferencedLiteObject
	 * ().getObjectID().getStringValue(); if(VERBOSE) { System.out.println((new
	 * StringBuilder
	 * ("    The Atts is: ")).append(theAtts[i].getName()).append("; The Value is: "
	 * ).append(sNodeId).toString()); System.out.println((new
	 * StringBuilder("    The Atts is: "
	 * )).append(theAtts[i].getName()).append("; The Value is: "
	 * ).append(((ReferenceValueDefaultView
	 * )theValues[j]).getLiteIBAReferenceable
	 * ().getIBAReferenceableDisplayString().toString())); } ObjectIdentifier
	 * nodeOID = ObjectIdentifier.newObjectIdentifier(sNodeId);
	 * clfNodes.add((ClassificationNode
	 * )PersistenceHelper.manager.refresh(nodeOID)); }
	 * 
	 * } } } if(VERBOSE) System.out.println((new
	 * StringBuilder("    \u83B7\u53D6\u5230 ")).append(clfNodes.size()).append(
	 * " \u7684\u5173\u8054\u7684\u5206\u7C7B\u8282\u70B9.").toString()); } else
	 * { System.out.println(" IBA container is null"); } } catch(Exception e) {
	 * e.printStackTrace(); } catch (RemoteException e) { e.printStackTrace(); }
	 * if(VERBOSE) System.out.println("<<<out CSMUtil.getClassNodesByPart()");
	 * return clfNodes; } public static String getClassificationRefDefinition()
	 * { String clsRefDefinition = ""; WTProperties wtp = null; try { wtp =
	 * WTProperties.getLocalProperties(); clsRefDefinition =
	 * wtp.getProperty("ext.generic.part.ClassificationReferenceDefinition",
	 * "Part"); } catch(IOException ioe) { clsRefDefinition = "Part"; } return
	 * clsRefDefinition; }
	 */
}
